package xyz.ddlnt.servicemq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import xyz.ddlnt.commonutil.util.RandomUtil;
import xyz.ddlnt.model.dto.UserContentInteractionDTO;
import xyz.ddlnt.model.entity.PostHistoryRecord;
import xyz.ddlnt.servicemq.mapper.PostHistoryRecordMapper;
import xyz.ddlnt.servicemq.service.PostHistoryRecordService;

import java.time.LocalDateTime;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/25 21:09
 */
@Service
public class PostHistoryRecordServiceImpl extends ServiceImpl<PostHistoryRecordMapper, PostHistoryRecord> implements PostHistoryRecordService {
    @Resource
    private PostHistoryRecordMapper postHistoryRecordMapper;

    @Override
    public void postHistoryRecordPlusOne(UserContentInteractionDTO userContentInteractionDTO) {
        PostHistoryRecord postHistoryRecord = PostHistoryRecord.builder()
                .id(RandomUtil.generate12DigitRandomNumber())
                .postId(userContentInteractionDTO.getId())
                .userId(userContentInteractionDTO.getUserId())
                .browseTime(LocalDateTime.now())
                .build();
        postHistoryRecordMapper.insert(postHistoryRecord);

    }
}
